﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using AjaxControlToolkit;
using System.Data;

using AjaxControlToolkit.Design;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Reflection;
using System.Security.Permissions;

using System.Web.UI.Design.WebControls;

namespace newWindow
{
   
  
    /// </summary>
    [
        TargetControlType(typeof(Control))
    ]
    [Bindable(true, BindingDirection.OneWay)]
      [DefaultBindingProperty("URL")]
    public class newWindowExtender : ExtenderControlBase 
    {
     public enum  yesno
        {           
       yes=1,
       no=0  
        }

        public yesno yn = new yesno();
        private bool? _show;
        public newWindowExtender() 
        {
            
             
            //
            // TODO: Add constructor logic here
            //
        }
        [ExtenderControlProperty]
     
               public virtual  string URL
        {
            get
            {
              
                return GetPropertyValue("URL", "");
            }
            set
            {
             
                SetPropertyValue("URL", value);
            }
        }
        
        [ExtenderControlProperty]
     
        public string Target
        {
        
          
            get
            {
                return GetPropertyValue("Target", "_blank");
            }
            set
            {
                SetPropertyValue("Target", value);
            }
        }

        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display the window in theater mode. The default is noInternet Explorer 7. channelmode = { yes | 1 } overrides height, width, top, and left values. When active, the Navigation Bar is hidden and the Title Bar is visible. The Channel Band is no longer supported in Internet Explorer 7. Prior to Internet Explorer 7 channelmode = { yes | 1 } displays the Channel Band in theatre mode.)")]
        public yesno Channelmode 
        {         
            get
            {
                return GetPropertyValue("Channelmode",yesno.no );
            }
            set
            {
                SetPropertyValue("Channelmode", value);
            }
        }
        [Browsable(true), ExtenderControlProperty,Description("Internet Explorer 7. This feature is no longer supported.")]
        public yesno Directories
        {
            get
            {
                return GetPropertyValue("Directories", yesno.no);
            }
            set  
            {
                SetPropertyValue("Directories", value);
            }
        }

        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display the browser in full-screen mode. The default is no. Use full-screen mode carefully. Because this mode hides the browser's title bar and menus, you should always provide a button or other visual clue to help the user close the window. ALT+F4 closes the new window. Internet Explorer 7. A window in full-screen mode does not need to be in theatre mode. Prior to Internet Explorer 7 a window in full-screen mode must also be in theater mode (channelmode).")]
        public yesno Fullscreen
        {
            get
            {

                return GetPropertyValue("Fullscreen", yesno.no);
            }
            set  
            {
                SetPropertyValue("Fullscreen", value);
            }
      }
        [Browsable(true), ExtenderControlProperty, Description("Internet Explorer 7. Specifies whether to display the navigation bar. The default is yes. Prior to Internet Explorer 7 this feature specifies whether to display the address bar. The Back, Forward, and Stop commands are now located in the Navigation bar. Prior to Internet Explorer 7 navigation commands were located in the toolbar.")]
        public yesno Location
        {
            get
            {

                return GetPropertyValue("Location", yesno.yes);
            }
            set
            {
                SetPropertyValue("Location", value);
            }
        }
        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display the menu bar. The default is yes. Internet Explorer 7. By default the menu bar is hidden unless revealed by the ALT key. menubar = { no | 0 } prohibits the menubar from appearing even when the Alt key is pressed. The combination of menubar = { no | 0 } and toolbar = { no | 0 } hides the toolbar and disables any additional third-party user interfaces. ")]
        public yesno Menubar 
        {
            get
            {

                return GetPropertyValue("Menubar", yesno.yes);
            }
            set
            {
                SetPropertyValue("Menubar", value);
            }
        }

        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display resize handles at the corners of the window. The default is yes. Internet Explorer 7. resizable = { no | 0 } disables tabs in a new window.")]
        public yesno Resizable
        {
            get
            {

                return GetPropertyValue("Resizable", yesno.yes);
            }
            set
            {
                SetPropertyValue("Resizable", value);
            }
        }
        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display horizontal and vertical scroll bars. The default is yes.")]
        public yesno Scrollbars 
        {
            get
            {

                return GetPropertyValue("Scrollbars", yesno.yes);
            }
            set
            {
                SetPropertyValue("Scrollbars", value);
            }
        }
        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to add a Status Bar at the bottom of the window. The default is yes.")]
        public yesno Status
        {
            get
            {

                return GetPropertyValue("Status", yesno.yes);
            }
            set
            {
                SetPropertyValue("Status", value);
            }
        }

        [Browsable(true), ExtenderControlProperty, Description("Specifies whether to display a Title Bar for the window. The default is yes. Internet Explorer 5.5 and later. This feature is no longer supported. The Title Bar remains visible unless the fullscreen sFeature is active. This parameter is ignored prior to Internet Explorer 5.5. It applies only if the calling application is an HTML Application or a trusted dialog box. ")]
            public yesno Titlebar
            {
                get
                {

                    return GetPropertyValue("Titlebar", yesno.yes);
                }
                set
                {
                    SetPropertyValue("Titlebar", value);
                }
            }
            [Browsable(true), ExtenderControlProperty, Description("Internet Explorer 7. Specifies whether to display the browser command bar, making buttons such as Favorites Center, Add to Favorites, and Tools available. The default is yes. The combination of menubar = { no | 0 } and toolbar = { no | 0 } turn off the Toolbar and any additional third-party user interfaces. Prior to Internet Explorer 7 the toolbar sFeature specifies whether to display the browser toolbar, making buttons such as Back, Forward, and Stop available. ")]
            public yesno Toolbar
            {
                get
                {

                    return GetPropertyValue("Toolbar", yesno.yes);
                }
                set
                {
                    SetPropertyValue("Toolbar", value);
                }
            }
            [Browsable(true), ExtenderControlProperty, Description("Specifies the top position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0. ")]
       
            public int Top 
        {
            get
            {

                return GetPropertyValue("Top",0);
            }
            set
            {
                SetPropertyValue("Top", value);
            }
        }
            [Browsable(true), ExtenderControlProperty, Description("Specifies the left position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0. ")]
       
            public int Left
            {
                get
                {

                    return GetPropertyValue("Left", 0);
                }
                set
                {
                    SetPropertyValue("Left", value);
                }
            }

         [Browsable(true), ExtenderControlProperty,  Description("Internet Explorer 7. Sets the height of the window in pixels. The minimum value is 150, and specifies the minimum height of the browser content area. Prior to Internet Explorer 7 the minimum height value is 100")]
         public int Height
         {
             get
             {
                 return GetPropertyValue("Height",200);
             }
             set
             {
                 SetPropertyValue("Height", value);
             }
         }


      [Browsable(true), ExtenderControlProperty,  Description("Internet Explorer 7. Sets the width of the window in pixels. The minimum value is 250, and specifies the minimum width of the browsers content area. Prior to Internet Explorer 7 the minimum height value is 100. ")]
      public int Width
      {
          get
          {
              return GetPropertyValue("Width", 200);
          }
          set
          {
              SetPropertyValue("Width", value);
          }
      }

        
        protected override IEnumerable<ScriptDescriptor>
                GetScriptDescriptors(System.Web.UI.Control targetControl)
        {
           
            ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("newWindow.ClientBehavior1", targetControl.ClientID);
            descriptor.AddProperty("URL", this.URL);
            descriptor.AddProperty("Target", this.Target);
             descriptor.AddProperty("Channelmode", this.Channelmode);
             descriptor.AddProperty("Directories", this.Directories);
             descriptor.AddProperty("Fullscreen", this.Fullscreen);
             descriptor.AddProperty("Location", this.Location);
             descriptor.AddProperty("Menubar", this.Menubar);
             descriptor.AddProperty("Resizable", this.Menubar);
             descriptor.AddProperty("Scrollbars", this.Scrollbars);
             descriptor.AddProperty("Status", this.Status);
             descriptor.AddProperty("Titlebar", this.Titlebar);
             descriptor.AddProperty("Toolbar", this.Toolbar);
             descriptor.AddProperty("Top", this.Top);
             descriptor.AddProperty("Left", this.Left);
             descriptor.AddProperty("Height", this.Height);
             descriptor.AddProperty("Width", this.Width);
            yield return descriptor;
        }

        // Generate the script reference
        protected override IEnumerable<ScriptReference>
                GetScriptReferences()
        {
            yield return new ScriptReference("newWindow.ClientBehavior1.js", this.GetType().Assembly.FullName);
        }
        public void Show()
        {
            _show = true;
           
        }
    }
}